home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 August / TommyVideo.iso / flash / volumes / volume_5.swf / scripts / %3Cdefault package%3E / FTraceAlertBoxSymbol.as < prev    next >
Encoding:
Text File  |  2003-06-08  |  10.7 KB  |  282 lines

  1. function FTraceAlertBoxClass()
  2. {
  3.    this.init();
  4. }
  5. FTraceAlertBoxClass.prototype = new FDraggablePaneClass();
  6. FTraceAlertBoxClass.prototype.init = function()
  7. {
  8.    this.attachMovie("ResizeBar_horizontal","resizeBar_horizontal_mc",this.level++,{controller:this});
  9.    this.attachMovie("ResizeBar_vertical","resizeBar_vertical_mc",this.level++,{controller:this});
  10.    this.resizeBar_vertical_mc.useHandCursor = false;
  11.    this.resizeBar_vertical_mc.onPress = this.resizeTrackBegin_vertical;
  12.    this.resizeBar_vertical_mc.onRelease = this.resizeTrackEnd;
  13.    this.resizeBar_vertical_mc.onReleaseOutside = this.resizeTrackEnd;
  14.    this.resizeBar_vertical_mc.onRollOver = this.setResizeCursor_vertical;
  15.    this.resizeBar_vertical_mc.onRollOut = this.restoreCursor;
  16.    this.resizeBar_horizontal_mc.useHandCursor = false;
  17.    this.resizeBar_horizontal_mc.onPress = this.resizeTrackBegin_horizontal;
  18.    this.resizeBar_horizontal_mc.onRelease = this.resizeTrackEnd;
  19.    this.resizeBar_horizontal_mc.onReleaseOutside = this.resizeTrackEnd;
  20.    this.resizeBar_horizontal_mc.onRollOver = this.setResizeCursor_horizontal;
  21.    this.resizeBar_horizontal_mc.onRollOut = this.restoreCursor;
  22.    this.traceText_fmt = new TextFormat();
  23.    this.traceText_fmt.font = "Courier";
  24.    this.createEmptyMovieClip("textHolder_mc",this.level++);
  25.    this.textHolder_mc.createTextField("trace_txt",this.level++,0,0,100,20);
  26.    this.textHolder_mc.trace_txt.type = "dynamic";
  27.    this.textHolder_mc.trace_txt.multiline = true;
  28.    this.textHolder_mc.trace_txt.wordWrap = true;
  29.    this.textHolder_mc.trace_txt.embedFonts = false;
  30.    this.textHolder_mc.trace_txt.autoSize = true;
  31.    this.setScrollContent(this.textHolder_mc);
  32.    super.init();
  33.    this.resizeGrip_mc.useHandCursor = false;
  34.    this.resizeCursor_mc.swapDepths(this.resizeBar_vertical_mc);
  35.    _global.traceComponent = this;
  36.    _global.traceAlert = function(msg)
  37.    {
  38.       if(!traceComponent.disableOnServer)
  39.       {
  40.          traceComponent.openPane(msg);
  41.       }
  42.       else if(_url.substr(0,4) != "http")
  43.       {
  44.          traceComponent.openPane(msg);
  45.       }
  46.    };
  47.    this._visible = 0;
  48. };
  49. FTraceAlertBoxClass.prototype.setResizable = function(resizable)
  50. {
  51.    super.setResizable(this.resizable);
  52.    this.resizeBar_vertical_mc._visible = resizable;
  53.    this.resizeBar_horizontal_mc._visible = resizable;
  54. };
  55. FTraceAlertBoxClass.prototype.setPaneSize = function(w, h)
  56. {
  57.    var newWidth = w;
  58.    var newHeight = h;
  59.    if(newWidth == undefined)
  60.    {
  61.       newWidth = 240;
  62.    }
  63.    if(newHeight == undefined)
  64.    {
  65.       newHeight = 180;
  66.    }
  67.    if(this.maxWidth > 0 && newWidth > this.maxWidth)
  68.    {
  69.       newWidth = this.maxWidth;
  70.    }
  71.    if(this.minWidth > 0 && newWidth < this.minWidth)
  72.    {
  73.       newWidth = this.minWidth;
  74.    }
  75.    if(newWidth < this.defaultMinimumWidth())
  76.    {
  77.       newWidth = this.defaultMinimumWidth();
  78.    }
  79.    if(this.maxHeight > 0 && newHeight > this.maxHeight)
  80.    {
  81.       newHeight = this.maxHeight;
  82.    }
  83.    if(this.minHeight > 0 && newHeight < this.minHeight)
  84.    {
  85.       newHeight = this.minHeight;
  86.    }
  87.    if(newHeight < this.defaultShadedHeight() + this.resizeGrip_mc._height)
  88.    {
  89.       newHeight = this.defaultShadedHeight() + this.resizeGrip_mc._height;
  90.    }
  91.    if(this.isShaded)
  92.    {
  93.       this.normalWidth = newWidth;
  94.       this.normalHeight = newHeight;
  95.       newHeight = this.defaultShadedHeight();
  96.    }
  97.    this.setSize(newWidth,newHeight);
  98. };
  99. FTraceAlertBoxClass.prototype.shadePane = function()
  100. {
  101.    super.shadePane();
  102.    this.resizeBar_vertical_mc._visible = false;
  103.    this.resizeBar_horizontal_mc._visible = false;
  104.    this.textHolder_mc._visible = false;
  105. };
  106. FTraceAlertBoxClass.prototype.restorePane = function()
  107. {
  108.    super.restorePane();
  109.    this.resizeBar_vertical_mc._visible = true;
  110.    this.resizeBar_horizontal_mc._visible = true;
  111.    this.textHolder_mc._visible = true;
  112. };
  113. FTraceAlertBoxClass.prototype.setResizeCursor_horizontal = function()
  114. {
  115.    this.controller.resizeCursor_mc.gotoAndStop(3);
  116.    this.controller.resizeCursor_mc._x = this.controller._xmouse - this.controller.resizeCursor_mc._width / 2;
  117.    this.controller.resizeCursor_mc._y = this.controller._ymouse - this.controller.resizeCursor_mc._height / 2;
  118.    this.controller.resizeCursor_mc._visible = true;
  119.    this.onMouseMove = this.controller.dragResizeCursor_horizontal;
  120.    Mouse.hide();
  121. };
  122. FTraceAlertBoxClass.prototype.setResizeCursor_vertical = function()
  123. {
  124.    this.controller.resizeCursor_mc.gotoAndStop(2);
  125.    this.controller.resizeCursor_mc._x = this.controller._xmouse - this.controller.resizeCursor_mc._width / 2;
  126.    this.controller.resizeCursor_mc._y = this.controller._ymouse - this.controller.resizeCursor_mc._height / 2;
  127.    this.controller.resizeCursor_mc._visible = true;
  128.    this.onMouseMove = this.controller.dragResizeCursor_vertical;
  129.    Mouse.hide();
  130. };
  131. FTraceAlertBoxClass.prototype.dragResizeCursor_vertical = function()
  132. {
  133.    this.controller.resizeCursor_mc._visible = true;
  134.    this.controller.resizeCursor_mc._x = this.controller._xmouse - this.controller.resizeCursor_mc._width / 2;
  135.    this.controller.resizeCursor_mc._y = this.controller._ymouse - this.controller.resizeCursor_mc._height / 2;
  136. };
  137. FTraceAlertBoxClass.prototype.dragResizeCursor_horizontal = function()
  138. {
  139.    this.controller.resizeCursor_mc._visible = true;
  140.    this.controller.resizeCursor_mc._x = this.controller._xmouse - this.controller.resizeCursor_mc._width / 2;
  141.    this.controller.resizeCursor_mc._y = this.controller._ymouse - this.controller.resizeCursor_mc._height / 2;
  142. };
  143. FTraceAlertBoxClass.prototype.restoreCursor = function()
  144. {
  145.    this.controller.resizeCursor_mc.gotoAndStop(1);
  146.    this.controller.resizeCursor_mc._visible = false;
  147.    this.onMouseMove = null;
  148.    Mouse.show();
  149. };
  150. FTraceAlertBoxClass.prototype.formatFrame = function(x, y, w, h)
  151. {
  152.    super.formatFrame(x,y,w,h);
  153.    var titleHeight = this.getTitlebarHeight();
  154.    var widgetSpacer = 2;
  155.    var thisWidth = w;
  156.    var thisHeight = h;
  157.    this.resizeBar_vertical_mc._y = titleHeight + 1;
  158.    this.resizeBar_vertical_mc._x = thisWidth - this.resizeBar_vertical_mc._width / 2;
  159.    this.resizeBar_vertical_mc._height = thisHeight - (titleHeight + 1) - 16;
  160.    this.resizeBar_horizontal_mc._x = 0;
  161.    this.resizeBar_horizontal_mc._y = thisHeight - this.resizeBar_horizontal_mc._height / 2;
  162.    this.resizeBar_horizontal_mc._width = thisWidth - 16;
  163.    this.textHolder_mc._x = 0;
  164.    this.textHolder_mc._y = titleHeight + 1;
  165. };
  166. FTraceAlertBoxClass.prototype.resizeTrackBegin = function()
  167. {
  168.    Mouse.hide();
  169.    this.controller.resizeCursor_mc._visible = true;
  170.    this.anchorX = this._xmouse;
  171.    this.anchorY = this._ymouse;
  172.    this.onMouseMove = function()
  173.    {
  174.       this.controller.dragResizeCursor();
  175.       var newWidth = this.controller.width + (this._xmouse - this.anchorX);
  176.       var newHeight = this.controller.height + (this._ymouse - this.anchorY);
  177.       if(newHeight < this.controller.defaultMinimumHeight())
  178.       {
  179.          newHeight = this.controller.defaultMinimumHeight();
  180.       }
  181.       this.controller.setPaneSize(newWidth,newHeight);
  182.       this.controller.scrollpane_mc.setScrollPosition(0,newHeight);
  183.    };
  184. };
  185. FTraceAlertBoxClass.prototype.resizeTrackBegin_vertical = function()
  186. {
  187.    Mouse.hide();
  188.    this.controller.resizeCursor_mc._visible = true;
  189.    this.anchorX = this._xmouse;
  190.    this.onMouseMove = function()
  191.    {
  192.       this.controller.dragResizeCursor();
  193.       var newWidth = this.controller.width + (this._xmouse - this.anchorX);
  194.       this.controller.setPaneSize(newWidth,this.controller.height);
  195.       this.controller.scrollpane_mc.setScrollPosition(0,this._height);
  196.    };
  197. };
  198. FTraceAlertBoxClass.prototype.resizeTrackBegin_horizontal = function()
  199. {
  200.    Mouse.hide();
  201.    this.controller.resizeCursor_mc._visible = true;
  202.    this.anchorY = this._ymouse;
  203.    this.onMouseMove = function()
  204.    {
  205.       this.controller.dragResizeCursor();
  206.       var newHeight = this.controller.height + (this._ymouse - this.anchorY);
  207.       if(newHeight < this.controller.defaultMinimumHeight())
  208.       {
  209.          newHeight = this.controller.defaultMinimumHeight();
  210.       }
  211.       this.controller.setPaneSize(this.controller.width,newHeight);
  212.       this.controller.scrollpane_mc.setScrollPosition(0,newHeight);
  213.    };
  214. };
  215. FDraggablePaneClass.prototype.titleTrackEnd = function(x, y)
  216. {
  217.    this.controller.stopDrag();
  218.    this.controller.preserveNormals();
  219. };
  220. FTraceAlertBoxClass.prototype.formatTitle = function(closeBoxOffset)
  221. {
  222.    var txtS = this.textStyle;
  223.    var sTbl = this.styleTable;
  224.    txtS.align = sTbl.textAlign.value != undefined ? undefined : (txtS.align = "left");
  225.    txtS.leftMargin = sTbl.textLeftMargin.value != undefined ? undefined : (txtS.leftMargin = 0);
  226.    txtS.rightMargin = sTbl.textRightMargin.value != undefined ? undefined : (txtS.rightMargin = 0);
  227.    txtS.leading = 0;
  228.    this.titleText_mc.labelField.setTextFormat(txtS);
  229.    var textWidth = this.titleText_mc.labelField.textWidth;
  230.    var textHeight = this.titleText_mc.labelField.textHeight;
  231.    this.titleText_mc._y = this.titleArea_mc._y + (this.titleArea_mc._height - textHeight) / 2 - 2;
  232.    if(this.textStyle.align == "center")
  233.    {
  234.       this.titleText_mc._x = this.titleArea_mc._x + (this.titleArea_mc._width - textWidth) / 2;
  235.    }
  236.    else if(this.textStyle.align == "left")
  237.    {
  238.       if(this.hasShader == false)
  239.       {
  240.          this.titleText_mc._x = this.titleArea_mc._x;
  241.       }
  242.       else
  243.       {
  244.          this.titleText_mc._x = this.titleArea_mc._x + this.shader_mc._x + this.shader_mc._width;
  245.       }
  246.    }
  247.    else if(this.textStyle.align == "right")
  248.    {
  249.       this.titleText_mc._x = closeBoxOffset - this.titleText_mc._width;
  250.    }
  251.    if(this.titleText_mc._x + this.titleText_mc._width > closeBoxOffset)
  252.    {
  253.       this.titleText_mc._x = closeBoxOffset - this.titleText_mc._width;
  254.    }
  255. };
  256. FTraceAlertBoxClass.prototype.openPane = function(traceMessage)
  257. {
  258.    this.traceMessage += traceMessage;
  259.    this.traceMessage += "\n";
  260.    if(!this._visible)
  261.    {
  262.       this._visible = true;
  263.    }
  264.    var tt = this.traceText_fmt.getTextExtent(this.traceMessage);
  265.    this.textHolder_mc.trace_txt._width = tt.width;
  266.    this.textHolder_mc.trace_txt.text = this.traceMessage;
  267.    this.textHolder_mc.trace_txt.setTextFormat(this.traceText_fmt);
  268.    this.textHolder_mc.trace_txt._width = this.textHolder_mc.trace_txt.textWidth + 7;
  269.    this.textHolder_mc.trace_txt._height = this.textHolder_mc.trace_txt.textHeight + 7;
  270.    this.setScrollContent(this.textHolder_mc);
  271.    this.controller.scrollpane_mc.setScrollPosition(0,this._height);
  272. };
  273. FTraceAlertBoxClass.prototype.closePane = function()
  274. {
  275.    if(this.closeHandler())
  276.    {
  277.       this.traceMessage = "";
  278.       this._visible = false;
  279.    }
  280. };
  281. Object.registerClass("FTraceAlertBoxSymbol",FTraceAlertBoxClass);
  282.